﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MaterialDemo.IService.IPermission;
using MaterialDemo.Model.DepartmentDTO;
using MaterialDemo.MVC.Filters;
using MaterialDemo.Utility;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

namespace MaterialDemo.MVC.Controllers
{
    [MySession]
    public class DepartmentController : Controller
    {
        #region 构造函数注入
        private readonly IDepartmentService _departmentService;
        private ILogger<DepartmentController> _logger;
        public DepartmentController(ILogger<DepartmentController> logger, IDepartmentService departmentService)
        {
            _departmentService = departmentService;
            _logger = logger;
        }
        #endregion

        #region 页面

        /// <summary>
        /// 部门信息页面
        /// </summary>
        /// <returns></returns>
        public IActionResult Index()
        {
            return View();
        }
        #endregion

        #region 非页面

   
        /// <summary>
        /// 获取部门分页信息
        /// </summary>
        /// <returns></returns>
        public string GetJsonList(int page, int limit, string selectInfo)
        {

            int totalCount = 0;
            List<DepartmentOutput> outlist = _departmentService.LoadPageEntities(page, limit, out totalCount, selectInfo);
            DataResult<List<DepartmentOutput>> dataResult = new DataResult<List<DepartmentOutput>>()
            {
                code = 0,
                msg = "ok",
                count = totalCount,
                data = outlist,
            };
            return JsonNetHelper.SerializetoJson(dataResult);
        }
          
        #endregion
    }
}